package xyz.xtt.exchange.service.impl;

import static java.util.stream.Collectors.toMap;

import java.util.Collection;
import java.util.Map;
import java.util.function.Function;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import xyz.xtt.exchange.entity.TblUserChainAccount;
import xyz.xtt.exchange.mapper.TblUserChainAccountMapper;
import xyz.xtt.exchange.service.ITblUserChainAccountService;

/**
 * <p>
 * 用户区块链账户表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-10-23
 */
@Service
public class TblUserChainAccountServiceImpl extends ServiceImpl<TblUserChainAccountMapper, TblUserChainAccount> implements ITblUserChainAccountService {

	@Override
	public Map<Long, TblUserChainAccount> queryAfterAdd(Collection<Long> userIds) {
		LambdaQueryChainWrapper<TblUserChainAccount> query = new LambdaQueryChainWrapper<>(baseMapper);
		return query
				.in(TblUserChainAccount::getAppUserId, userIds)
				.list()
				.stream()
				.collect(toMap(TblUserChainAccount::getAppUserId, Function.identity(), (a, b) -> b));
	}

}
